<?php 	
	include("head.php");
	include_once("paging_function.php");
?>
<script language="javascript" src="js/contactpopcalendar.js"></script>

<?php

/////////////////////////////////PAGING /////////////////

 	if(isset($_GET['page']) && $_GET['page']!='')

		{

		

			$page = $_GET['page'];

		}

	else

		{

			$page = 0;

		}

$limit=$adminpagelimit;

/////////////////////////////////////////////////////////////////	

?>

<?php

////////////////////////////////////////////    Block_---- DELETE  ///////////

if(isset($_POST['Submit']))

{

	$del=$_POST['del'];

	$no=count($del);

	if($no>0)

	{

	for($i=0;$i<$no;$i++)

	{

	   mysql_query("DELETE FROM ".CONTACTUS."  WHERE contactusId= '".$del[$i]."' ");	   

	}

	echo '<script>window.location="contact.php?dlt=1"</script>';

	}

	$block=$_POST['count_UPDATE'];

	
}



?>


<?php
		$searchsql="SELECT * FROM ".CONTACTUS." WHERE 1 "  ;
		if($_REQUEST['expiration_date']!='' && isset($_REQUEST['expiration_date']) && $_REQUEST['expiration_date2']!='' && isset($_REQUEST['expiration_date2']))
		{	
		$date1=$_POST['expiration_date'];		
		$date2=$_POST['expiration_date2'];

		$searchsql.=" AND `date` BETWEEN '".$date1."' AND '".$date2."'";

		}
		if($_REQUEST['name']!='' && isset($_REQUEST['name']))
		{
		$param="name=".$_REQUEST['name'];
		$searchsql.=" AND name like '".$_REQUEST['name']."%' ";

		}
		if($_REQUEST['email']!='' && isset($_REQUEST['email']))
		{
		$param="email=".$_REQUEST['email'];
		$searchsql.=" AND name like '".$_REQUEST['email']."%'";

		}
	
		else
		{
		$searchsql.=" ORDER BY contactusId  DESC";
		}
		$searchsql.=" limit $page,$limit";

		$searchquery=mysql_query($searchsql);// or die('error1'.mysql_error());

//echo $searchsql;	

?>


 <table width="100%" border="0" cellspacing="0" cellpadding="3" style="border:1px solid #666666">
<tr><td >&nbsp;</td></tr>
<tr><td >&nbsp;</td></tr>
<tr> 
			<td height="15" align="center" style="color:#000000;font-size:12px;">
				<font color="#000000"><strong> CONTACT MANAGEMENT </strong></font>
			</td> 
		</tr>
<tr><td >&nbsp;</td></tr>
<tr><td >&nbsp;</td></tr>
   <tr><td>

  		<table width="100%" border="0" cellspacing="0" cellpadding="3" class="tabbod">

  			<?php
			
				if(isset($_REQUEST['action']))
				
				{
				
				$editquery=mysql_query("SELECT * FROM ".CONTACTUS." WHERE contactusId='".$_REQUEST['contactusId']."'");
				
				$fetch=mysql_fetch_array($editquery);
				
			?>
>
   <tr><td colspan="7" id="edit_section" style="display:;">

<fieldset><legend class="LEGEND"> Contact Details</legend>

<form name="edit" action="" method="POST" onSubmit="return check();" >

<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">

    <tr>

      <td width="17%" align="left" id="admin_text">Contact Name</td>

      <td width="2%" align="left">::</td>

      <td width="81%" align="left"><input name="name" type="text" value="<?php echo $fetch['name'];?>" size="42" readonly=""></td>
    </tr>

    <tr>

      <td width="17%" align="left" id="admin_text">Email</td>

      <td width="2%" align="left">::</td>

      <td width="81%" align="left"><input name="name2" type="text" value="<?php echo $fetch['email'];?>" size="42" readonly="">        &nbsp;</td>
    </tr>
  <tr>

      <td width="17%" align="left" id="admin_text">phone</td>

      <td width="2%" align="left">::</td>

      <td width="81%" align="left"><input name="name2" type="text" value="<?php echo $fetch['phone1'];?>" size="42" readonly="">&nbsp;</td>
    </tr>
    <tr>

      <td width="17%" align="left" id="admin_text">Address</td>

      <td width="2%" align="left">::</td>

      <td width="81%" align="left"><input name="name2" type="text" value="<?php echo $fetch['address'];?>" size="42" readonly="">        &nbsp;</td>
    </tr>
    <tr>

      <td width="17%" align="left" id="admin_text">City</td>

      <td width="2%" align="left">::</td>

      <td width="81%" align="left"><input name="name2" type="text" value="<?php echo $fetch['city'];?>" size="42" readonly="">        &nbsp;</td>
    </tr>
    <tr>

      <td width="17%" align="left" id="admin_text">State</td>

      <td width="2%" align="left">::</td>

      <td width="81%" align="left"><input name="name2" type="text" value="<?php echo $fetch['state'];?>" size="42" readonly="">        &nbsp;</td>
    </tr>
    <tr>

      <td width="17%" align="left" id="admin_text">Country</td>

      <td width="2%" align="left">::</td>

      <td width="81%" align="left"><input name="name2" type="text" value="<?php echo $fetch['country'];?>" size="42" readonly="">        &nbsp;</td>
    </tr>
    <tr>

      <td width="17%" align="left" id="admin_text">IP</td>

      <td width="2%" align="left">::</td>

      <td width="81%" align="left"><input name="name2" type="text" value="<?php echo $fetch['userIp'];?>" size="42" readonly="">        &nbsp;</td>
    </tr>
    <tr>

      <td width="17%" align="left" id="admin_text">Message</td>

      <td width="2%" align="left">::</td>

      <td width="81%" align="left"><textarea  name="message"  cols="40" rows="7" readonly="readonly"><?php  echo stripslashes($fetch['content']);?></textarea></td>
    </tr>


    <tr>

      <td align="center">&nbsp;</td>

    <td align="center">&nbsp;</td>

    <td align="left">&nbsp;
      
      <input type="button" value="Close" name="close_frm" id="close_frm" onClick="window.location='contact.php';" /></td></tr></table>
</form>
</fieldset>

  <?php } ?>

  </td></tr>
<form name="datesearch" method="POST">
   <tr>
      <td colspan="2">Search By Date : </td>
      <td height="40" colspan="5" align="left" valign="middle"><strong> Date</strong>
        <input name="expiration_date" type="text" class="inplogin" id="expiration_date" value="<?php echo $_REQUEST['expiration_date'];?>" size="10" >
        &nbsp;&nbsp;<img src="images/calendar.gif" width="19" height="15" onClick="popUpCalendar(this, document.all.expiration_date, 'yyyy-mm-dd');" align="absmiddle" />
&nbsp;&nbsp;<strong>To</strong>
<input name="expiration_date2" type="text" class="inplogin" id="expiration_date2" value="<?php echo $_REQUEST['expiration_date2'];?>" size="10" >
&nbsp;&nbsp;<img src="images/calendar.gif" width="19" height="15" onClick="popUpCalendar(this, document.all.expiration_date2, 'yyyy-mm-dd');" align="absmiddle" />&nbsp;Search By Name <input type="text" name="name" value="<?php echo $_POST['name']; ?>" size="10">&nbsp;Search By Email <input type="text" name="email" value="<?php echo $_POST['email']; ?>" size="10">&nbsp;
<input type="submit" name="Submit1" value="Search" /></td>

      
    </tr>
<tr><td colspan="7" align="left"><a href="contact.php" style="color:#000000;font-size:12px;">View All</a></td></tr>
</form>

    <?php
  if(mysql_num_rows($searchquery)>0)

	  {
	  ?><form name="form_admin_management" action="" method="post">
	
		<tr bgcolor="#6F8DBC">	
		  <td width="4%" height="28" style="color:#ffffff;font-size:12px;"><strong>S.No</strong></td>	
		  <td width="11%" valign="middle" style="color:#ffffff;font-size:12px;"><strong>User Name </strong></td>	
		  <td width="26%" valign="middle" style="color:#ffffff;font-size:12px;" align="left"><strong>User Email  </strong></td>
		  <td width="36%" valign="middle" style="color:#ffffff;font-size:12px;" align="left"><strong>Message </strong></td>
		  <td style="color:#ffffff;font-size:12px;" width="12%"><strong>Date</strong></td>	
		  <td width="5%" align="center" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Details</strong></td>	
		  <td align="center" valign="middle" style="color:#ffffff;font-size:12px;"><strong>Delete</strong></td>
		</tr>
	
		<?php 
	
	  $count=0;
	
	  $sno=1;
	
	  $loop=0;
	
	  while($searcharray=mysql_fetch_array($searchquery))
	
	  {
	  
	
	  $loop++;
	
			if($loop == 1)
	
			 $bgcolor = "#F0F0FF";
	
			else 
	
			$bgcolor = "#CCCCFF";
	
	?>
	
		<tr bgcolor="<?php echo $bgcolor; ?>">
	
		  <td height="32" style="color:#000000;font-size:12px;"><strong><?php echo $sno+$_GET['page'];//echo $searcharray['usercode']; ?></strong></td>
	
		  <td align="left" valign="middle" style="color:#000000;font-size:12px;"><?php echo ucfirst($searcharray['name']); ?></td>
	
		  <td align="left" valign="middle"  style="color:#000000;font-size:12px;"><a href="mailto:<?php echo $searcharray['email'];?>"><?php echo $searcharray['email'];?></a></td>
		  <td align="left" valign="middle" style="color:#000000;font-size:12px;" ><?php $rest =$searcharray['content'];
		   echo substr("$rest",0,30);?>....</td>
		 <td align="left"><?php echo $searcharray['date'];?> </td>
		  <td align="center" valign="middle"><a href="contact.php?action=details&contactusId=<?php echo $searcharray['contactusId'];?>" ><img src="images/edit_icon.gif" border="0"/></a></td>
	
		  <td align="center" valign="middle"><input type="checkbox" name="del[]" value="<?php echo $searcharray['contactusId'];?>"></td>
		  </tr>
	
		<?php 
	
	  $count++;
	
	  $sno++;
	
			 if($loop == 2)
	
				{
	
				$loop = 0;
	
				}	
	
			 }
	
			   ?>
	
		<tr>
	
		  <td colspan="4">&nbsp;</td>
	
		  <td colspan="2" align="right"><input type="hidden" name="c9ount_UPDATE" value="<?php echo $count; ?>">
	
			  <input type="submit" name="Submit" value="Update"></td>
		</tr>
	
		<tr>
	
		  <td colspan="6" align="center" style="color:#FF0000"><?php echo paging($searchsql,$page,$limit,'',$param);?></td>
		</tr>
	
		<?php
	
	
	
	  }

 else
 
	 {
?>

<tr bgcolor="#6F8DBC">

      <td style="color:#ffffff;font-size:12px;"><strong>S.No</strong></td>

	  <td width="11%" style="color:#ffffff;font-size:12px;"><strong>User   Name </strong></td>

	  <td width="27%" style="color:#ffffff;font-size:12px;"><strong>User Email </strong></td>
	  <td width="36%" align="center" style="color:#ffffff;font-size:12px;"><strong>Message</strong></td>
		<td width="12%" align="center" style="color:#ffffff;font-size:12px;"><strong>Date</strong></td>
      <td width="5%" align="center" style="color:#ffffff;font-size:12px;"><strong>Details</strong></td>

      <td align="center" style="color:#ffffff;font-size:12px;"><strong>Delete</strong></td>
      </tr>

    <tr>

      <td colspan="10" align="left"  class="DISPLAYMESSAGES">&nbsp;&nbsp;&nbsp;No Result Found!</td>
    </tr>

    <?php

     }
   ?></form>
  </table>

  </td></tr></table>



<?php 



include("foot.php");?>